<!-- 编辑开票信息组件 -->
<template>
  <el-dialog
    :title="dialogTitle"
    :visible.sync="visible"
    width="600px"
    append-to-body
    :close-on-click-modal="false"
  >
    <el-form ref="form" :model="formData" label-width="140px">
      <el-form-item label="发票种类" prop="invoiceCategory">
        <el-radio-group v-model="formData.invoiceCategory">
          <el-radio
            v-for="(label, value) in dict.invoice_category"
            :key="value"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="发票类型" prop="invoiceType">
        <el-radio-group v-model="formData.invoiceType">
          <el-radio
            v-for="(label, value) in dict.invoice_type"
            :key="value"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="单位名称" prop="invoiceUnitName">
        <el-input
          v-model="formData.invoiceUnitName"
          placeholder="请输入单位名称"
        />
      </el-form-item>
      <el-form-item label="单位统一信用代码" prop="invoiceCreditCode">
        <el-input
          v-model="formData.invoiceCreditCode"
          placeholder="请输入单位统一信用代码"
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancel">取 消</el-button>
      <el-button type="primary" @click="handleSubmit">提 交</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "EditInvoiceInfoDialog",
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    formData: {
      type: Object,
      default: () => ({
        invoiceType: "普票", // 默认为普票
        invoiceCategory: "企业", // 默认为企业
        invoiceUnitName: "",
        invoiceCreditCode: "",
      }),
    },
    dict: {
      type: Object,
      default: () => ({}),
    },
  },
  computed: {
    dialogTitle() {
      return "编辑开票信息";
      // return this.formData.id ? '编辑开票信息' : '新增开票信息';
    },
  },
  methods: {
    handleCancel() {
      this.$emit("close");
    },
    handleSubmit() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.$emit("submit", this.formData);
        }
      });
    },
  },
};
</script>

<style scoped>
.dialog-footer {
  text-align: right;
}
</style>